.class public Lcom/brixd/niceapp/util/SoundUtils;
.super Ljava/lang/Object;
.source "SoundUtils.java"


# instance fields
.field private context:Landroid/content/Context;

.field private soundPool:Landroid/media/SoundPool;

.field private soundPoolMap:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljava/lang/Integer;",
            "Ljava/lang/Integer;",
            ">;"
        }
    .end annotation
.end field

.field streamVolume:I


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 2
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 12
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 13
    iput-object p1, p0, Lcom/brixd/niceapp/util/SoundUtils;->context:Landroid/content/Context;

    .line 14
    invoke-virtual {p0}, Lcom/brixd/niceapp/util/SoundUtils;->initSounds()V

    .line 15
    return-void
.end method


# virtual methods
.method public initSounds()V
    .registers 6

    .prologue
    const/4 v4, 0x3

    .line 28
    new-instance v1, Landroid/media/SoundPool;

    const/4 v2, 0x7

    const/16 v3, 0x64

    invoke-direct {v1, v2, v4, v3}, Landroid/media/SoundPool;-><init>(III)V

    iput-object v1, p0, Lcom/brixd/niceapp/util/SoundUtils;->soundPool:Landroid/media/SoundPool;

    .line 31
    new-instance v1, Ljava/util/HashMap;

    invoke-direct {v1}, Ljava/util/HashMap;-><init>()V

    iput-object v1, p0, Lcom/brixd/niceapp/util/SoundUtils;->soundPoolMap:Ljava/util/HashMap;

    .line 34
    iget-object v1, p0, Lcom/brixd/niceapp/util/SoundUtils;->context:Landroid/content/Context;

    const-string v2, "audio"

    invoke-virtual {v1, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/media/AudioManager;

    .line 35
    .local v0, "mgr":Landroid/media/AudioManager;
    invoke-virtual {v0, v4}, Landroid/media/AudioManager;->getStreamVolume(I)I

    move-result v1

    iput v1, p0, Lcom/brixd/niceapp/util/SoundUtils;->streamVolume:I

    .line 36
    return-void
.end method

.method public loadSfx(II)V
    .registers 8
    .param p1, "raw"    # I
    .param p2, "id"    # I

    .prologue
    .line 40
    iget-object v0, p0, Lcom/brixd/niceapp/util/SoundUtils;->soundPoolMap:Ljava/util/HashMap;

    invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    iget-object v2, p0, Lcom/brixd/niceapp/util/SoundUtils;->soundPool:Landroid/media/SoundPool;

    iget-object v3, p0, Lcom/brixd/niceapp/util/SoundUtils;->context:Landroid/content/Context;

    const/4 v4, 0x0

    invoke-virtual {v2, v3, p1, v4}, Landroid/media/SoundPool;->load(Landroid/content/Context;II)I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 41
    return-void
.end method

.method public play(II)V
    .registers 10
    .param p1, "sound"    # I
    .param p2, "uLoop"    # I

    .prologue
    .line 44
    iget-object v0, p0, Lcom/brixd/niceapp/util/SoundUtils;->soundPool:Landroid/media/SoundPool;

    iget-object v1, p0, Lcom/brixd/niceapp/util/SoundUtils;->soundPoolMap:Ljava/util/HashMap;

    invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/Integer;

    invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I

    move-result v1

    iget v2, p0, Lcom/brixd/niceapp/util/SoundUtils;->streamVolume:I

    int-to-float v2, v2

    iget v3, p0, Lcom/brixd/niceapp/util/SoundUtils;->streamVolume:I

    int-to-float v3, v3

    const/4 v4, 0x1

    const/high16 v6, 0x3f800000

    move v5, p2

    invoke-virtual/range {v0 .. v6}, Landroid/media/SoundPool;->play(IFFIIF)I

    .line 45
    return-void
.end method
